package org.alvin.gencode;

import com.alibaba.excel.EasyExcelFactory;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ExcelTemplateDemo {

    //    https://blog.csdn.net/sad555ssss/article/details/117521688
    public static void main(String[] args) throws IOException {
//        int value1 = Integer.MAX_VALUE;
//        int value2 = Integer.MAX_VALUE - 1 ;
//        System.out.println(value1+","+ value2);
//        value1 ^= value2;
//        System.out.println(value1);
//        value2 ^= value1;
//        System.out.println(value2);
//        value1 ^= value2;
//        System.out.println(value1);
//        InputStream is = Files.newInputStream(Paths.get("E:", "test.xlsx"));
//        List<LinkedHashMap> list = EasyExcelFactory.read(is).sheet(0).doReadSync();
//        System.out.println(list);
//        Map<String, Object> map = new HashMap<String, Object>();
//
//        // 获取模板路径
//        String templateFileName = FileUtil.getPath() + "excel/exportArchiveList2.xls";
//        // 创建输出的excel对象
//        final ExcelWriter write = EasyExcel.write(outputStream).withTemplate(templateFileName).build();
//        // 创建第一个sheel页
//        final WriteSheet sheet1 = EasyExcel.writerSheet(0,"材料列表1").build();
//        // 创建第二个sheel页
//        final WriteSheet sheet2 = EasyExcel.writerSheet(1,"材料列表2").build();
//
//        // 设置列表横向展示
//        FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
//        // 使用数据横向展示的示例
//        // write.fill(list,fillConfig,sheet1);
//
//        write.fill(list, sheet1);
//        map.put("total", "材料列表1");
//        write.fill(map, sheet1);
//
//        write.fill(list, sheet2);
//        map.put("total", "材料列表2");
//        write.fill(map, sheet2);
//
//        // 关闭流
//        write.finish()
//        String jobno = "FQCL20220818015";
//        String regex = "([A-Z]+)[0-9]+";
//        Pattern pattern = Pattern.compile(regex);
//        Matcher matcher = pattern.matcher(jobno);
//        if(matcher.find()){
//            System.out.println(matcher.group(1)+"---");
//        }


        
    }
}
